# -*- coding: utf-8 -*-
"""
Created on 2022/11/14 上午2:06

@author: chenfei
"""

from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TCompactProtocol

import MyRpc.rpc.MyRpcService as rpc

'''
执行代码
'''
def run_sql(userToken, sql, ps):
    rs = None;
    sk = TSocket.TSocket('127.0.0.1', '8091');
    transport = TTransport.TFramedTransport(sk);
    try:
        protocal = TCompactProtocol.TCompactProtocol(transport);
        '''
        创建客户端
        '''
        client = rpc.Client(protocal);
        transport.open();

        rs = client.executeSqlQuery(userToken, sql, ps);
    except Exception as ex:
        print(ex.message);
    finally:
        transport.close();
    return rs;













































